package cn.wolfcode.domain;

import com.alibaba.fastjson.JSON;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
@Getter
@Setter
public class Notice {
    /** */
    private Long id;

    /** */
    private String title;

    /** */
    private String content;

    /** */
    private Employee createUser;

    /** */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
    private Date createTime;

    /** */
    private Integer level;

    /** */
    private Boolean rel=false;

    private Boolean readStatus;

    public String getLev(){
        if (this.level==0){
            return "普通";
        }else if (this.level==1){
            return "重要";
        } else if (this.level==2){
            return "紧急";
        }
        return "";
    }

    @Override
    public String toString() {
        return JSON.toJSONString(this);
    }

    public String getTimeStatus(){
        Date now = new Date();
        long nowTime = now.getTime();
        long createTime = this.createTime.getTime();
        Long time= (nowTime-createTime)/1000/60;
        if (time>=60){
            return time/60 +"小时前";
        }

        return time + "分钟前";
    }
}